<template>
    <div style="margin: 0 10px 0 10px">
        <div style="margin: 10px">
            标题: <Input v-model="dataFilter.title" size="small" placeholder="" style="width: 120px" />
            求助人: <Input v-model="dataFilter.helpUserName" size="small" placeholder="" style="width: 120px" />
            <Button type="primary" shape="circle" icon="ios-search" style="margin-left: 15px" @click="loadData"></Button>
            <div style="float: right">
                <Button type="primary" to="/donate/help/apply" style="margin-left:10px ">申请求助</Button>
            </div>
        </div>
        <!--<div style="margin: 10px">
            <Button type="primary" @click="handleAdd">新增</Button>
        </div>-->
        <Table :data="tableData"  :columns="columns"  highlight-row  :loading="loading">
            <template slot-scope="{ row }" slot="title">
                <router-link   :to="{ name: 'donate_help_view', query: { id:row.id } }">{{row.title}}</router-link >
            </template>
            <template slot-scope="{ row, index }" slot="action">
                <Button type="primary" size="small" style="margin-right: 5px" @click="handleView(row,index)">查看</Button>
                <Button type="primary" size="small" style="margin-right: 5px" @click="handleEdit(row,index)">审核</Button>
                <Button type="error" size="small" @click="handleRemove(row,index)">删除</Button>
            </template>
        </Table>
        <div style="margin: 25px;overflow: hidden">
            <div style="float: right;">
                <Page :total="total" :current="dataFilter.current" :page-size="dataFilter.size"
                      show-sizer
                      @on-change="changePage" @on-page-size-change="changeSize" :page-size-opts="[10,20,50,100]"></Page>
            </div>
        </div>
    </div>
</template>
<script>
    import Base from '@/components/table/BaseList';
    export default {
        components:{
        },
        extends:Base,
        data () {
            return {
                columns: [
                    { type: 'index', width: 60, align: 'center'},
                    { title: '标题', key: 'title',slot:'title'},
                    /*{ title: '求助内容详情', key: 'content'},*/
                    { title: '求助人', width: 250, key: 'helpUserName'},
                    { title: '创建时间', width: 250, key: 'createTime' }
                ]
            }
        },
        mounted(){
            this.loadData();
        },
        methods: {
            handleEdit(row){
                //审核功能
                this.editModal=true;
                this.$refs.editModal.loadDataById(row.id);
            },handleView(row){
                //查看功能
                this.viewModal=true;
                this.$refs.viewModal.loadDataById(row.id);
            },
            loadData(){
                //获取列表数据
                this.dataFilter.auditResult="01";
                this.baseLoadData('/api/help/list');
            },handleAdd(){
                //新增功能
                this.editModal=true;
                this.$refs.editModal.loadDataById(null);
            },handleRemove(row){
                //删除
                this.baseRemove('/api/help/delete',{id:row.id});
            }
        }
    }
</script>
